Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[consensus] Add proposer role #3814

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Feb 20, 2023

Description

In order to implement execution node, firstly the block proposor is no longer choosen from delegates but from a new group named proposors in each round. The main changes are:

  • calculator proposor from proposors group
  • only proposor will broadcast block proposal

Currently, the delegates and proposors should be the same list so that the actual consensus process could be consistent with past.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented Feb 20, 2023

Codecov Report

Merging #3814 (84d561c) into master (263ff82) will increase coverage by 0.89%.
The diff coverage is 79.74%.

❗ Current head 84d561c differs from pull request most recent head 92beede. Consider uploading reports for the commit 92beede to get more accurate results

@@            Coverage Diff             @@
##           master    #3814      +/-   ##
==========================================
+ Coverage   74.47%   75.37%   +0.89%     
==========================================
  Files         269      303      +34     
  Lines       23925    25933    +2008     
==========================================
+ Hits        17818    19546    +1728     
- Misses       5174     5363     +189     
- Partials      933     1024      +91     
Impacted Files Coverage Δ
action/actctx.go 90.62% <ø> (+6.25%) ⬆️
action/action.go 82.35% <ø> (ø)
action/action_deserializer.go 57.14% <ø> (ø)
action/candidate_update.go 88.88% <0.00%> (-4.14%) ⬇️
action/consignment_transfer.go 90.41% <ø> (ø)
action/const.go 100.00% <ø> (ø)
action/execution.go 83.78% <ø> (ø)
action/grantreward.go 68.57% <ø> (ø)
action/protocol/account/protocol.go 86.90% <ø> (ø)
action/protocol/dock.go 100.00% <ø> (ø)
... and 284 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@envestcc envestcc marked this pull request as ready for review February 20, 2023 15:23
@CoderZhi CoderZhi changed the title [consensus] Add proposors in consensus [consensus] Add proposer role in consensus Feb 23, 2023
@CoderZhi CoderZhi changed the title [consensus] Add proposer role in consensus [consensus] Add proposer role Feb 23, 2023
Copy link
Collaborator

@CoderZhi CoderZhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: proposer

}
return addrs, nil
}
// TODO implement proposorsByEpochFunc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a TODO

@@ -177,6 +183,12 @@ func (c *roundCalculator) Delegates(height uint64) ([]string, error) {
return c.delegatesByEpochFunc(epochNum)
}

// Delegates returns list of proposors at given height
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Proposers returns a list of candidate proposers at given height

@@ -408,11 +408,13 @@ func (m *ConsensusFSM) prepare(evt fsm.Event) (fsm.State, error) {
}

overtime := m.ctx.WaitUntilRoundStart()
if proposal != nil {
Copy link
Member

@dustinxie dustinxie Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed? since delegates only receive proposal, don't need to broadcast proposal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or as phase 1, ENode and CNode still use the same dpos code?
if that's the plan, need to add the IsENode() in the consensus/dpos module? since lots of code/funcs will only used by CNode

@sonarcloud
Copy link

sonarcloud bot commented Mar 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
38.5% 38.5% Duplication

@CoderZhi CoderZhi merged commit 2fc3ba0 into iotexproject:master Mar 6, 2023
@envestcc envestcc deleted the consensus_proposor branch April 18, 2023 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants